package com.situ.day8;

import java.awt.List;
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map.Entry;
import java.util.Set;

import javax.print.attribute.HashAttributeSet;

import org.junit.Test;
import org.junit.experimental.theories.suppliers.TestedOn;
import org.omg.CORBA.PUBLIC_MEMBER;

import com.situ.day3.Students;

public class lianxi {
	@Test
	public void test1(){
		ArrayList<Students>list = new ArrayList<>();
		Students student1 = new Students(1, "zhangsan", 19, "java1");
		Students student2 = new Students(2, "zhangsan1", 21, "java2");
		Students student3 = new Students(3, "zhangsan2", 22, "java3");
		list.add(student1);
		list.add(student2);
		list.add(student3);
		for (Students students : list) {
			System.out.println(students);
		}
		System.out.println("----------------------------------");
		HashSet<Students>set = new HashSet<>();
		Students student4 = new Students(1, "zhangsan", 19, "java1");
		Students student5 = new Students(2, "zhangsan1", 21, "java2");
		Students student6 = new Students(3, "zhangsan2", 22, "java3");
		set.add(student4);
		set.add(student5);
		set.add(student6);
		set.add(student4);
		for (Students students2 : set) {
			System.out.println(student2);
			System.out.println("-----------------------------------------");
		}
	}
	@Test
	public void test(){

		HashMap<String, String>map = new HashMap<>();
		map.put("CN", "中华人民共和国");
		map.put("Us", "美利坚合众国");
		//根据key，找出key对应的值value；
		String valuel = map.get("CN");
		System.out.println(valuel);
		
		//Map遍历
		Set<Entry<String,String>>entrySet = map.entrySet();
		for (Entry<String, String> entry : entrySet) {
			String key = entry.getKey();
			String value = entry.getValue();
			System.out.println("Key" + key);
			System.out.println("value" + value);
			System.out.println("--------------");
			Set<String>keySet = map.keySet();
			for (String string : keySet) {
				System.out.println("key" + key);
				String value1 = map.get(key);
				System.out.println("value" + value);
			}
		}
		
	}

}
